package com.jh.netty.hj2122017.pojo;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.util.Map;

/**
 * 实时数据
 *
 * 数据库（t_realtime_data）
 */
@Setter
@Getter
@ToString
public class RealTimeData {

    private Long id;

    /**
     * 数据监测时间 精确到秒 yyyyMMddHHmmss
     */
    private String dataTime;

    /**
     * PM2.5
     */
    private String a34004Rtd;

    /**
     * PM2.5 标记
     */
    private String a34004Flag;

    /**
     * PM10
     */
    private String a34002Rtd;

    /**
     * PM10 标记
     */
    private String a34002Flag;

    /**
     * TSP
     */
    private String a34001Rtd;

    /**
     * TSP 标记
     */
    private String a34001Flag;

    /**
     * 温度
     */
    private String a01001Rtd;

    /**
     * 温度标记
     */
    private String a01001Flag;

    /**
     * 湿度
     */
    private String a01002Rtd;

    /**
     * 湿度标记
     */
    private String a01002Flag;

    /**
     * 大气压
     */
    private String a01006Rtd;

    /**
     * 大气压标记
     */
    private String a01006Flag;

    /**
     * 风速
     */
    private String a01007Rtd;

    /**
     * 风速标记
     */
    private String a01007Flag;

    /**
     * 风向
     */
    private String a01008Rtd;

    /**
     * 风向标记
     */
    private String a01008Flag;

    /**
     * 噪声
     */
    private String a50001Rtd;

    /**
     * 噪声标记
     */
    private String a50001Flag;

    public static RealTimeData from(Map<String, String> map) {
        String dt = map.get("DataTime");

        RealTimeData rtd = new RealTimeData();
        rtd.setDataTime(dt);
        rtd.a01001Rtd = map.get("a01001-Rtd");
        rtd.a01001Flag = map.get("a01001-Flag");

        rtd.a01002Rtd = map.get("a01002-Rtd");
        rtd.a01002Flag = map.get("a01002-Flag");

        rtd.a01006Rtd = map.get("a01006-Rtd");
        rtd.a01006Flag = map.get("a01006-Flag");

        rtd.a01007Rtd = map.get("a01007-Rtd");
        rtd.a01007Flag = map.get("a01007-Flag");

        rtd.a01008Rtd = map.get("a01008-Rtd");
        rtd.a01008Flag = map.get("a01008-Flag");

        rtd.a34001Rtd = map.get("a34001-Rtd");
        rtd.a34001Flag = map.get("a34001-Flag");

        rtd.a34002Rtd = map.get("a34002-Rtd");
        rtd.a34002Flag = map.get("a34002-Flag");

        rtd.a34004Rtd = map.get("a34004-Rtd");
        rtd.a34004Flag = map.get("a34004-Flag");

        rtd.a50001Rtd = map.get("a50001-Rtd");
        rtd.a50001Flag = map.get("a50001-Flag");

        return rtd;
    }
}
